import { _decorator, Component, Node, Sprite, SpriteFrame, sys } from 'cc';
import oh from './OhCtrl';
const { ccclass, property } = _decorator;
declare var window: any

@ccclass('DarkCtrl')
export class DarkCtrl extends Component {
    @property(Sprite)
    bgs:Sprite[] = []

    @property(SpriteFrame)
    light:SpriteFrame[] = []

    @property(SpriteFrame)
    dark:SpriteFrame[] = []

    static ins:DarkCtrl;

    onLoad() {
        DarkCtrl.ins = this;
        this.setState(oh.getDarkState());
    }

    setState(state:boolean = true){
        this.bgs.forEach((bg,index)=>{
            bg.spriteFrame = state?this.light[index]:this.dark[index];
        })
    }

}

